# @Time    :2025/3/28 17:05
"""
# 需求：完成一个实现两个数+、-、*、/简单计算的计算器
"""

"""
def sum1(num1, num2):
    return num1 + num2


def jian(num1, num2):
    return num1 - num2


def chen(num1, num2):
    return num1 * num2


def dels(num1, num2):
    return num1 / num2


# 定义一个计算函数，接收参与运算的两个数，并调用相关的运算方法去进行计算

def cal(num1, num2, op):
    return op(num1, num2)


print(cal(20, 10, sum1))
print(cal(20, 30, chen))
print(cal(20, 30, dels))
print(cal(20, 30, jian))

"""


# 定义一个计算函数，接收参与运算的两个数，并调用相关的运算方法去进行计算,lambda实现

def cal(num1, num2, op):
    return op(num1, num2)


print(cal(20, 10, lambda num1, num2: num1 - num2))
print(cal(12, 9, lambda a, b: a - b))
print(cal(34, 3, lambda a, b: a * b))
print(cal(12, 2, lambda a, b: a / b))

